package org.easyexcel.Test;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author DPF
 */
public class MyRenntLock {
    public static void main(String[] args) {
        ReentrantLock lock = new ReentrantLock();
        new Thread(() -> {
            boolean b = lock.tryLock();
            try {
                if (!b) {
                    System.out.println("获取锁失败1111");
                }
                System.out.println("获取锁成功1111");
            }catch (Exception e) {
                e.printStackTrace();
            } finally {
                try {
                    lock.unlock();
                    System.out.println("释放锁成功1111");
                } catch (Exception e) {
                    System.out.println("释放锁失败1111");
                }
            }
        }).start();

        lock.lock();
        System.out.println("获取锁成功...");
        lock.unlock();
        System.out.println("释放锁成功...");
    }
}

